package org.example.game.history;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/30 10:52
 */
public class Solution100340 {

    public static void main(String[] args) {
        System.out.println(new Solution100340().maxHeightOfTriangle(2, 1));
    }


    public int maxHeightOfTriangle(int red, int blue) {
        int ans = 1;

        int line = 1;
        int max = red;
        int min = blue;

        while (true){
            if(line%2 == 0){
                min -= line;
                if(max <= line){
                    break;
                }
            }else {
                max -= line;
                if(min <= line){
                    break;
                }
            }
            line++;
        }

        ans = Math.max(ans, line);

        line = 1;
        max = blue;
        min = red;

        while (true){
            if(line%2 == 0){
                min -= line;
                if(max <= line){
                    break;
                }
            }else {
                max -= line;
                if(min <= line){
                    break;
                }
            }
            line++;
        }

        ans = Math.max(ans, line);

        return ans;
    }

}
